---
title: "Row Selection API Reference"
description: "Selection API Reference for Single and Multi-Row Selection in the $framework Table."
---

Selection API Reference for Single and Multi-Row Selection

{% note %}
The row selection state can be saved and restored as part of [Grid State](./grid-state/).
{% /note %}

## Configuration API

### Single Row Mode

{% interfaceDocumentation interfaceName="SingleRowSelectionOptions" config={"description":""} /%}

### Multi-Row Mode

{% interfaceDocumentation interfaceName="MultiRowSelectionOptions" config={"description":""} /%}

## Selection Events

There are two events with regards to selection, illustrated in the example below:

{% apiDocumentation source="grid-events/events.json" section="selection" names=["rowSelected", "selectionChanged"] /%}

The example below has configured messages to be logged to the developer console on both these events firing. Click a row while the developer console is open to see an illustration of the events.

{% gridExampleRunner title="Selection Events" name="selection-events" /%}

## Node Selection API

To select rows programmatically, use the `node.setSelected(params)` method.

{% apiDocumentation source="row-object/properties.json" section="selection" names=["setSelected", "isSelected"] /%}

For example:

```{% frameworkTransform=true %}
// set selected, keep any other selections
node.setSelected(true);

// set selected, exclusively, remove any other selections
node.setSelected(true, true);

// un-select
node.setSelected(false);

// check status of node selection
const selected = node.isSelected();
```

## Grid Selection API

The grid API has the following methods for selection:

{% apiDocumentation source="grid-api/api.json" section="selection" names=["selectAll","deselectAll","getSelectedNodes", "getSelectedRows", "setNodesSelected"] /%}

If you want to select only the filtered rows, you could do this using the following:

```js
// loop through each node after filter
const nodes = [];
api.forEachNodeAfterFilter(node => {
    nodes.push(node);
});
api.setNodesSelected({ nodes, newValue: true });
```

## Next up

Continue to the next section to learn about [Cell Selection](./cell-selection).
